package com.atguigu.day211103.work.test07.bean;

import com.atguigu.day211103.work.test06.bean.Rectangle;

public class Test08 {
    public static void main(String[] args) {
        Rectangle[] r = new Rectangle[5];
        r[0] = new Rectangle(Math.random() * 10, Math.random() * 10);
        r[1] = new Rectangle(Math.random() * 10, Math.random() * 10);
        r[2] = new Rectangle(Math.random() * 10, Math.random() * 10);
        r[3] = new Rectangle(Math.random() * 10, Math.random() * 10);
        r[4] = new Rectangle(Math.random() * 10, Math.random() * 10);

        for (int i = 0; i < r.length; i++) {
            System.out.println(r[i].getInfo());
        }
        System.out.println("------------------------------------------------------------------");
        for (int i = 1; i < r.length; i++) {
            for (int j = 0; j < r.length - i; j++) {
                if (r[j].getArea() > r[j + 1].getArea()) {
                    Rectangle temp = r[j];
                    r[j] = r[j + 1];
                    r[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < r.length; i++) {
            System.out.println(r[i].getInfo());
        }
    }
}
